package com.itheimamobileguard.activitys;

import com.example.mobile.R;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;



public class Setup3Activity extends BaseSetUpActivity{
	
	private EditText et_phone;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_setup3);
		et_phone = (EditText) findViewById(R.id.et_phone);
		et_phone.setText(sp.getString("safeNum", ""));
	}
	

	@Override
	public void showNext() {
		String safeNum = et_phone.getText().toString().trim();
		if (TextUtils.isEmpty(safeNum)) {
			Toast.makeText(getApplicationContext(), "请输入安全号码", 0).show();
			return;
		}
		Editor editor = sp.edit();
		editor.putString("safeNum", safeNum);
		editor.commit();
		startAndFinshActivity(Setup4Activity.class);
	}

	@Override
	public void showPre() {
		startAndFinshActivity(Setup2Activity.class);		
	}
	
	public void select_contact(View view){
		Intent intent = new Intent(this,SelectContactActivity.class);
		startActivityForResult(intent, 0);
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (data != null) {
			String phone = data.getStringExtra("phone");
			et_phone.setText(phone);
		}
		super.onActivityResult(requestCode, resultCode, data);
	}
}
